<template>
	<view>
	
	</view>
</template>

<script>
	const app = getApp().globalData
	import {
		errorsList,
		deleteErrors
	} from '../../../common/path.js'
	export default {
		data() {
			return {
				errorsDataList: [],
				optionid: 1
			}
		},
		onLoad(option) {
			if (option.id) {
				this.optionid = option.id
			}
			this.errorsList()

		},
		methods: {
			//查询错题
			errorsList() {
				let data = {
					uid: app.userInfo.id,
					type: this.optionid //1科目1 2 科目4
				}
				this.$axios.axios("POST", errorsList, data)
					.then(res => {
						console.log('回答错的===>', res.data)
						let errorsDataList = res.data
						// let setdataarr = Array.from(new Set(errorsDataList))
						// console.log('错题',setdataarr);
						this.errorsDataList = errorsDataList
					})
					.catch(err => {
						console.log(err)
					})
			},
			// 删除错题
			ErrosMen(id) {
				let that = this
				uni.showModal({
					title: '温馨提示',
					content: '确定要删除该错题吗？',
					success: function(Res) {
						if (Res.confirm) {
							that.deleteErros(id)
						} else if (Res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},

			deleteErros(id) {
				let data = {
					id: id
				}
				this.$axios.axios("POST", deleteErrors, data)
					.then(res => {
						console.log('回答错的===>', res.msg)
						this.errorsList()
						this.$tools.showToast(res.msg)
					})
					.catch(err => {
						console.log(err)
					})
			}
		}
	}
</script>

<style>
</style>
